package com.jwx.mycar.service.impl;

import com.jwx.mycar.entity.po.Recognition;
import com.jwx.mycar.mapper.PictureMapper;
import com.jwx.mycar.mapper.RecognitionMapper;
import com.jwx.mycar.service.RecognitionService;
import com.jwx.mycar.utils.KeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RecognitionServiceImpl implements RecognitionService {


	@Autowired
    PictureMapper pictureMapper;
	@Autowired
    RecognitionMapper recognitionMapper;
	@Override
	public void save(List<Recognition> list) {
		if (list == null || list.size() <= 0) return;
		String picId = list.get(0).getPicId();
		List<Recognition> existList = recognitionMapper.findByPicId(picId);
		// 已经存在识别结果，跳过
		if (existList.size() > 0) return;
		for(Recognition rec:list){
			rec.setReId(KeyUtil.genUniqueKey());
		}
		boolean success =recognitionMapper.save(list);
	}


}
